/*
 * main.cpp
 * 
 * Copyright 2014 julian
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 * 
 * 
 */


#include <iostream>
#include "Ej1.h"
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main(int argc, char **argv){
	
	Ej1 ej1;
	pair<vector<unsigned short>,bool> salida;
	
	unsigned int numTablones,saltoMax;
	unsigned short val;
	
	cin >> numTablones;
	
	while(numTablones!= 0){	
		cin >> saltoMax;
		
		vector<unsigned short> entrada;
		entrada.push_back(0);
		
		//Cargo tablones
		for(unsigned int pos = 0;pos<numTablones;pos++){
			cin  >> val;
			entrada.push_back(val);
		}
		entrada.push_back(0);	
		
		salida = ej1.ejecutar(entrada,saltoMax);
		
		//Si tiene solución la muestro
		if(salida.second){
			cout << salida.first.size();
			for (vector<unsigned short>::iterator it = salida.first.begin(); it != salida.first.end(); ++it){
				cout << ' ' << *it;
			}
			cout << endl;
		}else
			cout << "no" <<endl;
			
		 cin >> numTablones;
	}
	return 0;
}

